<template>
  <div class="main">
    <Menu v-if="bookmarks?.length" :bookmarks="bookmarks"></Menu>
    <Upload v-else></Upload>
  </div>
</template>
<script lang="ts">
import { getGlobal, IStorage, IHTMLSystem, IRequest } from "@/utils";
import Upload from "./layout/upload/index.vue";
import Menu from "./layout/menu/index.vue";
let request: IRequest;
let storage: IStorage;
let htmlSystem: IHTMLSystem;

export default {
  components: { Menu, Upload },
  data() {
    request = getGlobal("request");
    storage = getGlobal("storage");
    htmlSystem = getGlobal("htmlSystem");
    return {
      bookmarks: storage.getStorage("bookmarks"),
    };
  },
  mounted: async function () {
    const hadInfo = storage.getStorage("hadInfo");
    if (!hadInfo) {
      const res = await request.GET(
        "http://website.diehunter1024.work/bookmarks.html"
      );
      this.bookmarks = htmlSystem.initHTML(await res.text());
      storage.setStorage("bookmarks", this.bookmarks);
    }
  },
};
</script>



<style>
* {
  margin: 0;
  padding: 0;
}
</style>
